import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsEmail, IsOptional, MaxLength } from 'class-validator';
import type { IUpdateProfile } from '@nbase/shared';

/**
 * 更新个人信息 DTO
 */
export class UpdateProfileDto implements IUpdateProfile {
  @ApiPropertyOptional({
    description: '昵称',
    example: '张三',
    maxLength: 50,
  })
  @IsOptional()
  @IsString()
  @MaxLength(50, { message: '昵称长度不能大于 50' })
  nickname?: string;

  @ApiPropertyOptional({
    description: '邮箱',
    example: 'zhangsan@example.com',
    maxLength: 50,
  })
  @IsOptional()
  @IsEmail({}, { message: '邮箱格式不正确' })
  @MaxLength(50, { message: '邮箱长度不能大于 50' })
  email?: string;

  @ApiPropertyOptional({
    description: '手机号',
    example: '13800138000',
    maxLength: 20,
  })
  @IsOptional()
  @IsString()
  @MaxLength(20, { message: '手机号长度不能大于 20' })
  mobile?: string;

  @ApiPropertyOptional({
    description: '头像URL',
    example: 'https://example.com/avatar.jpg',
    maxLength: 512,
  })
  @IsOptional()
  @IsString()
  @MaxLength(512, { message: '头像URL长度不能大于 512' })
  avatar?: string;
}

